package cn.taobaoke.restful.domain;


import cn.taobaoke.restful.util.Constants;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author yangzuo
 * @since 2017-03-25
 */
@Setter
@Getter
@ToString
@Entity
@Table(name = "tb_config")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GlobalConfig implements Serializable {

    public static final String CONFIG_TYPE_DEFAULT = "default";

    @Id
    @GeneratedValue
    private Long id;

    @Column
    private String type; // 内容为'default'

    @Column(length = 3000)
    private String globalConfig; // 全局配置

    @Column
    private String logoUrl;     // 商品logo

    @Column
    private String title;       // 商品title

    @Column
    private Long domainId;

    @Transient
    public static final String TJ_PID = "mm_120456523_22556802_74748128";

    public static Map<String, Object> DEFAULT_MAP = new HashMap<String, Object>() {
        {
            put(Constants.SERVICE_FEE_RATIO, 15);           // 阿里妈妈默认提取技术服务费 15%点
            put(Constants.CLASS1_PER_OF_COMMISSION, 10);    // 一级抽成比率 10% (扣除阿里妈妈服务费之后)
            put(Constants.CLASS2_PER_OF_COMMISSION, 5);     // 二级抽成 5% (扣除阿里妈妈服务费之后)
            put(Constants.PROMOTER_PER_OF_COMMISSION, 45);  // 默认推广者 提取 40% (扣除阿里妈妈服务费之后)
            put(Constants.ADMIN_PID, TJ_PID);                   // 默认管理员的推广位PID
            put(Constants.IMAGE_ROOT, "/data/images");
        }
    };

}
